#Boa:Frame:Frame_localIDAgenda

import wx
from ControleAgendamento import *
import random

def create(parent):
    return Frame_localIDAgenda(parent)

[wxID_FRAME_LOCALIDAGENDA, wxID_FRAME_LOCALIDAGENDABUTTON1, 
 wxID_FRAME_LOCALIDAGENDABUTTON2, wxID_FRAME_LOCALIDAGENDAPANEL1, 
 wxID_FRAME_LOCALIDAGENDASTATICBOX1, wxID_FRAME_LOCALIDAGENDASTATICTEXT1, 
 wxID_FRAME_LOCALIDAGENDATEXTCTRL1, wxID_FRAME_LOCALIDAGENDAWINDOW1, 
] = [wx.NewId() for _init_ctrls in range(8)]

class Frame_localIDAgenda(wx.Frame):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Frame.__init__(self, id=wxID_FRAME_LOCALIDAGENDA,
              name=u'Frame_localIDAgenda', parent=prnt, pos=wx.Point(559, 182),
              size=wx.Size(393, 208), style=wx.DEFAULT_FRAME_STYLE,
              title=u'Frame_localIDAgenda')
        self.SetClientSize(wx.Size(377, 170))

        self.panel1 = wx.Panel(id=wxID_FRAME_LOCALIDAGENDAPANEL1, name='panel1',
              parent=self, pos=wx.Point(0, 0), size=wx.Size(377, 170),
              style=wx.TAB_TRAVERSAL)

        self.window1 = wx.Window(id=wxID_FRAME_LOCALIDAGENDAWINDOW1,
              name='window1', parent=self.panel1, pos=wx.Point(32, 21),
              size=wx.Size(312, 131), style=0)
        self.window1.Center(wx.HORIZONTAL)

        self.staticBox1 = wx.StaticBox(id=wxID_FRAME_LOCALIDAGENDASTATICBOX1,
              label=u'Entre com o ID do Agendamento', name='staticBox1',
              parent=self.window1, pos=wx.Point(8, 8), size=wx.Size(296, 64),
              style=0)

        self.textCtrl1 = wx.TextCtrl(id=wxID_FRAME_LOCALIDAGENDATEXTCTRL1,
              name='textCtrl1', parent=self.window1, pos=wx.Point(112, 32),
              size=wx.Size(100, 24), style=0, value=u'A')
        self.textCtrl1.SetMaxLength(5)

        self.staticText1 = wx.StaticText(id=wxID_FRAME_LOCALIDAGENDASTATICTEXT1,
              label=u'ID', name='staticText1', parent=self.window1,
              pos=wx.Point(80, 32), size=wx.Size(14, 16), style=0)
        self.staticText1.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD,
              False, u'Tahoma'))

        self.button1 = wx.Button(id=wxID_FRAME_LOCALIDAGENDABUTTON1,
              label=u'OK', name='button1', parent=self.window1, pos=wx.Point(48,
              88), size=wx.Size(56, 32), style=0)
        self.button1.Bind(wx.EVT_BUTTON, self.OnButton1Button,
              id=wxID_FRAME_LOCALIDAGENDABUTTON1)

        self.button2 = wx.Button(id=wxID_FRAME_LOCALIDAGENDABUTTON2,
              label=u'Cancelar', name='button2', parent=self.window1,
              pos=wx.Point(192, 88), size=wx.Size(80, 31), style=0)
        self.button2.Bind(wx.EVT_BUTTON, self.OnButton2Button,
              id=wxID_FRAME_LOCALIDAGENDABUTTON2)

    def __init__(self, parent):
        self._init_ctrls(parent)

    def OnButton2Button(self, event):
        self.Close()

    def OnButton1Button(self, event):
        ca = ControleAgendamento()
        ca.verificarArquivo()
        
        agendamento = ca.procurarAgendamentoID(self.textCtrl1.GetValue())
        print agendamento.GetConcluido()
        if agendamento == None:
            wx.MessageBox('ID invalido','Pagamento',wx.OK)
        else:
            if agendamento.GetConcluido() == True:
                wx.MessageBox('Pagamento do ID ja Efetuado','Pagamento',wx.OK)
            elif agendamento.GetConcluido() == False:
                import Frame_EfetuarPagamento
                Frame_EfetuarPagamento.create(None, None, self.textCtrl1.GetLabel()).Show()
                self.Close()
